package com.xbongbong.pro.message.pojo.dto;/*/*/

import com.alibaba.dingtalk.openapi.newmessage.entity.OA;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.paas.toolbox.wrap.QueryIgnore;
import com.xbongbong.pro.message.pojo.PushRefTypePojo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 消息推送  走消息队列，用于传输数据的
 * @author 魏荣杰
 * @date 2019/2/26 14:56
 * @since v1.0
 * @version v1.0
 */
@Getter
@Setter
@ToString
public class MessageRabbitMqDTO {
    /**
     * 公司id
     */
    @NotNull(message = "{dto.msg.messageRabbitMq.corpid.NotNull}")
    String corpid;
    /**
     * 被推送对象
     */
    @NotNull(message = "{dto.msg.messageRabbitMq.userIds.NotNull}")
    List<String> userIds;
    /**
     * 关联业务id
     */
    List<Long> refIds;
    /**
     * 是否为提醒消息 0：不是（默认）   1：是
     */
    Integer remind;
    /**
     * 推送时间
     */
    Long pushTime;
    /**
     * 消息体的标题
     */
    @NotNull(message = "{dto.msg.messageRabbitMq.title.NotNull}")
    String title;
    /**
     * 消息体的内容，最多显示3行
     */
    String content;
    /**
     * 表单部分数据
     */
    List<OA.Body.Form> form;
    /**
     * web端系统内跳转所需参数
     */
    PushRefTypePojo.Options options;

    /**
     * 跳过重复提交校验，主要用于接口自动化测试
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private Boolean ignoreConCheck;

    public MessageRabbitMqDTO() {
        this.remind = 0;
        this.pushTime = DateTimeUtil.getInt();
    }

    public MessageRabbitMqDTO(@NotNull(message = "公司id不可为空") String corpid, @NotNull(message = "被推送对象不可为空") List<String> userIds, List<Long> refIds, Integer remind, Long pushTime, @NotNull(message = "消息体的标题不可为空") String title, String content, List<OA.Body.Form> form, @NotNull(message = "options不可为空") PushRefTypePojo.Options options) {
        this.corpid = corpid;
        this.userIds = userIds;
        this.refIds = refIds;
        this.remind = remind == null ? 0 : remind;
        this.pushTime = pushTime == null ? DateTimeUtil.getInt() : pushTime;
        this.title = title;
        this.content = content;
        this.form = form;
        this.options = options;
    }
}
